﻿using Microsoft.EntityFrameworkCore;
using Traceability_2203.Common.DBcontexts;
using Traceability_2203.Common.Infrastructure.interFaces;
using Traceability_2203.Common.Infrastructure.Repostories;

namespace Traceability_2203.Api.Common
{
    /// <summary>
    /// 拓展方法 静态类 +静态方法+this关键词
    /// </summary>
    public static class ExtensionServiceCollection
    {

        public static void AddService(this IServiceCollection services,IConfiguration configuration)
        {


            //调用静态方法EF上下文
            services.AddDBContext(configuration);


            services.AddHttpContextAccessor();
            services.AddScoped<IdentityService, LIdentityService>();

            //可以吧Prop里面粘过来      
       
        }

        public static void AddDBContext(this IServiceCollection service,IConfiguration configuration)
        {

            //EF上下文
            service.AddDbContext<EFDBcontexts>(x => x.UseSqlServer(configuration.GetConnectionString("DB")));



        }
    }
}
